<?php
namespace app\index\model;
use think\Model;
use think\Db;
use think\Cache;

class Type extends Model
{
	public function getNavData($id = [])
	{
		return self::field('type_id, type_name, nav_id')
						->when($id, function($query) use ($id){
							$id = is_array($id) ? $id : [$id];
							$query->where('nav_id', 'in', $id);
						})
						->where('is_show', 1)
						->order('type_sort desc,type_id asc')
						->select();
	}

	public function getOneData($id)
	{
		return self::field('type_id,type_name,is_free,type_desc')
						->where('type_id', $id)
						->where('is_show', 1)
						->find();
	}
}